/*
 * MIT License
 * 
 * Copyright (c) 2017 wen.gu <454727014@qq.com>
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/***************************************************************************
* Name: vos_version.h
*
* Purpose: about version struct and interface define
*
* Developer:
*   wen.gu , 2014-06-07
*
* TODO:
*
***************************************************************************/

#include "vos_version.h"

//////////////////////////////////////////////////////////////////////////
vosVersion_t vosGetVersion(void)
{
    vosVersion_t version;
    version.s.nVersionMajor = VOS_MAJOR_VERSION_NUM;
    version.s.nVersionMinor = VOS_MINOR_VERSION_NUM;
    version.s.nRevision     = VOS_REVISION_VERSION_NUM;
    version.s.nStep         = VOS_STEP_VERSION_NUM;


    return version;
}


GU08 vosGetVersionMajor(void)
{
    return VOS_MAJOR_VERSION_NUM;
}


GU08 vosGetVersionMinor(void)
{
    return VOS_MINOR_VERSION_NUM;
}


GU08 vosGetVersionRevision(void)
{
    return VOS_REVISION_VERSION_NUM;
}


GU08 vosGetVersionStep(void)
{
    return VOS_STEP_VERSION_NUM;
}

GBOL vosIsVersionAtLeast(GU08 major, GU08 minor, GU08 revision, GU08 step)
{
    GBOL ret = GFALSE;

    if (VOS_MAJOR_VERSION_NUM > major)
    {
        ret = GTRUE;
    }
    else if (VOS_MAJOR_VERSION_NUM == major)
    {
        if (VOS_MINOR_VERSION_NUM > minor)
        {
            ret = GTRUE;
        }
        else if (VOS_MINOR_VERSION_NUM == minor)
        {
            if (VOS_REVISION_VERSION_NUM > revision)
            {
                ret = GTRUE;
            }
            else if (VOS_REVISION_VERSION_NUM == revision)
            {
                if (VOS_STEP_VERSION_NUM >= step)
                {
                    ret = GTRUE;
                }
            }
        }
    }

    return ret;
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

vosReleaseDate_t vosGetReleaseDate(void)
{
    vosReleaseDate_t rDate;
    rDate.s.nDay   = VOS_RELEASE_DAY;
    rDate.s.nMonth = VOS_RELEASE_MONTH;
    rDate.s.nYear  = VOS_RELEASE_YEAR;

    return rDate;
}


GU08 vosGetReleaseDay(void)
{
    return VOS_RELEASE_DAY;
}


GU08 vosGetReleaseMonth(void)
{
    return VOS_RELEASE_MONTH;
}


GU16 vosGetReleaseYear(void)
{
    return VOS_RELEASE_YEAR;
}

GBOL vosIsDateAtLeast(GU16 year, GU08 month, GU08 day)
{
    GBOL ret = GFALSE;

    if (VOS_RELEASE_YEAR > year)
    {
        ret = GTRUE;
    }
    else if (VOS_RELEASE_YEAR == year)
    {
        if (VOS_RELEASE_MONTH > month)
        {
            ret = GTRUE;
        }
        else if (VOS_RELEASE_MONTH == month)
        {
            if (VOS_RELEASE_DAY >= day)
            {
                ret = GTRUE;
            }
        }
    }

    return ret;
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

const char* vosGetBuildInfo(void)
{
#if defined(VOS_BUILD_INFO)
    static const char buildInfo[] = __DATE__ __TIME__;
#else
    static const char* buildInfo = __DATE__;
#endif
    return buildInfo;
}
